package com.fr.report.script.function;

import com.fr.base.core.DateUtils;
import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import java.util.Date;
import java.util.GregorianCalendar;

public class HOUR extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    Date localDate = DateUtils.object2Date(paramArrayOfObject[0], false);
    GregorianCalendar localGregorianCalendar = new GregorianCalendar();
    localGregorianCalendar.setTime(localDate);
    return new Integer(localGregorianCalendar.get(11));
  }

  public Function.Type getType()
  {
    return Function.DATETIME;
  }

  public String getCN()
  {
    return "HOUR(serial_number):返回某一指定时间的小时数。函数指定HOUR为0（0:00）到23（23:00)之间的一个整数。\nSerial_number:包含所求小时的时间。\n示例:\nHOUR(\"11:32:40\")等于11。\nHOUR(\"11:32:40\", \"HH:mm:ss\")等于11。";
  }

  public String getEN()
  {
    return "HOUR(serial_number): Returns the hour of a time value. The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).\nSerial_number is the time that contains the hour you want to find.\n\nExample:\n   HOUR(\"11:32:40\") = 11\n   HOUR(\"11:32:40\", \"HH:mm:ss\") = 11   ";
  }
}